<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>入栏登记</title>
    <link rel="stylesheet" href="../../../../public/dist/css/layui.css">
    <link rel="stylesheet" href="../../../../public/font/iconfont.css">
    <link rel="stylesheet" href="../../../../css/twocss/commit.css">
</head>

<body>
    <form class="layui-form" action="">
        <div class="select common">
            <div class="select-title">查询条件</div>

            <div class="select-con">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">种苗名称:</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="seedname">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商:</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="supplyname">
                        </div>
                    </div>
                </div>




                <div class="layui-form-item">
                    <div class="select-hand-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">入栏日期:</label>
                            <input type="text" class="layui-input" id="startDate" value="2000-01-01">
                            <div style="margin:0 10px;">至</div>
                            <input type="text" class="layui-input" id="endDate" value="2100-01-01">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">入栏单号:</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="ordercode">
                        </div>
                    </div>
                </div>


                <div class="select-btn">
                    <div class="layui-bg-green comquery Rawquery">查询</div>
                    <div class="layui-bg-green comquery ">重置</div>
                </div>
            </div>

        </div>
    </form>

    <div class="common-padding">
        <table class="layui-hide" id="test" lay-filter="testdome"></table>
    </div>

</body>
<!-- 头部 -->
<script type="text/html" id="toolbarinter">
    <div class="layui-btn-container ">
        <button class="layui-btn  layui-btn-sm colors" lay-event="add"><i class="layui-icon"></i></i>添加</button>
        <button class="layui-btn  layui-btn-sm colors" lay-event="update"><i class="layui-icon"></i>查看</button>
        <!-- <button class="layui-btn  layui-btn-sm colors" lay-event="delete"><i class="layui-icon"></i>删除</button> -->
    </div>
</script>

<!-- 里面的查看 -->
<script type="text/html" id="More">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
</script>
<script src="../../../../js/common/jquery.min.js"></script>
<script src="../../../../js/common/api.js"></script>
<script src="../../../../public/dist/layui.js" charset="utf-8"></script>
<script src="../../../../js/common/template-web.js"></script>
<!-- <script src="../../../../js/two/Efarming/registered.js"></script> -->
<script>
(function(){
    layui.use(["table",'laydate'], function() {
        var $ = layui.jquery,
          table = layui.table;
          laydate = layui.laydate;

            laydate.render({ 
                elem: '#startDate' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            });
            laydate.render({ 
                elem: '#endDate' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            });
           //监听头部监听
            table.on('toolbar(testdome)', function(obj) {
                var checkStatus = table.checkStatus(obj.config.id),
                    data = checkStatus.data; //获取选中的数据
                switch (obj.event) {
                    case 'add':
                            window.location.href = "./dialog/registeredDialog.html";
                        break;
                    case 'update':
                        if(data.length === 0){
                            layer.msg('请选择一行');
                        } else if(data.length > 1){
                            layer.msg('只能同时编辑一个');
                        } else {
                            window.location.href = "./dialog/registeredDialog.html?id="+data[0].id;
                        }
                        break;
                    // case 'delete':
                    //     if (data.length === 0) {
                    //         layer.msg('请选择一行');
                    //     } else {
                    //         deleteId(data[0].id);
                    //     }
                    //     break;
                };
            });

            function deleteId(id){
                Theoldcuiway(
                    "plant/deleteNcpxx", {
                        ncpxxId:id,
                    },
                    "POST"
                )
                .done(function(resp) {
                    console.log(resp);
                    layer.msg('删除成功');
                    setTimeout(function(){
                        getList();
                    },1500)
                    return;
                })
                .fail(function(err) {
                    console.log(err);
                });
            }
          document.querySelector('.Rawquery').addEventListener('click',function(){
            getList();
          })
          getList();
          function getList(){
              var seedname = document.querySelector('#seedname').value;
              var supplyname = document.querySelector('#supplyname').value;
              var startDate = document.querySelector('#startDate').value;
              var endDate = document.querySelector('#endDate').value;
              var ordercode = document.querySelector('#ordercode').value;
            //获取列表
            var tableIns = table.render({
                elem: "#test",
                url: baseaip + "breed/rldjs",
                method: "GET",
                where: {
                    seedName:seedname,
                    supplyName:supplyname,
                    startDate:new Date(startDate) ,
                    endDate:new Date(endDate),
                    orderCode:ordercode,
                },
                headers: {
                Authorization: "Bearer" + " " + sessions
                },
                request: {
                pageName: "page",
                limitName: "limit"
                },
                limits: [10, 20],
                parseData: function(res) {
                //res 即为原始返回的数据
                console.log(res);
                return {
                    code: res.code, //解析接口状态
                    msg: res.msg, //解析提示文本
                    totalNum: res.data.totalElements, //解析数据长度
                    lists: res.data.content //解析数据列表
                };
                },
                toolbar: "#toolbarinter",
                response: {
                statusName: "code", //数据状态的字段名称，默认：code
                statusCode: 200, //成功的状态码，默认：0
                msgName: "msg", //状态信息的字段名称，默认：msg
                countName: "totalNum", //数据总数的字段名称，默认：count
                dataName: "lists" //数据列表的字段名称，默认：data
                },
                cellMinWidth: 80,
                page: {
                //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ["prev", "page", "next", "skip", "count"], //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                groups: 5, //只显示 1 个连续页码
                first: true, //不显示首页
                last: true, //不显示尾页
                prev: "下一页",
                next: "上一页",
                theme: "#c81623"
                },
                // height: 'full-20',//满高
                cols: [
                [
                    {
                        type: 'checkbox', 
                        fixed: 'left'
                    },{
                    title: "编号",
                    type: "numbers",
                    align: "center",
                    },
                    {
                    field: "ordercode",
                    title: "入栏单号",
                    minWidth: 120,
                    align: "center"
                    },
                   
                    {
                    field: "orderdate",
                    title: "入栏日期",
                    minWidth: 120,
                    align: "center",
                    templet:function(data){
                        console.log(data.orderdate);
                        var yymmdd =  new Date(data.orderdate);
                        return yymmdd.getFullYear() + '-' + (yymmdd.getMonth() + 1) + '-' + yymmdd.getDate()
                    }
                    },
                    {
                    field: "supplytype",
                    title: "供应商类型",
                    minWidth: 120,
                    align: "center",
                    templet:function (data) {
                        console.log(data.supplytype);
                        if(data.supplytype==1){
                            return '企业供应商'
                        }else{
                            return '个人供应商'
                        }
                    }
                    },
                    {
                    field: "supplyname",
                    title: "供应商名称",
                    minWidth: 120,
                    align: "center"
                    },
                    {
                    field: "seedname",
                    title: "种苗名称",
                    minWidth: 50,
                    align: "center"
                    },
                    
                ]
                ]
            });
          }
        
      });
})()
</script>

</html>